Skip to content

Support string-length() XPath function without an argument#337

Merged
naitoh merged 1 commit into
ruby:masterfrom
SAY-5:fix-string-length-no-argument
Jul 5, 2026
Merged

Support string-length() XPath function without an argument#337
naitoh merged 1 commit into
ruby:masterfrom
SAY-5:fix-string-length-no-argument

Conversation

@SAY-5

@SAY-5 SAY-5 commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Per XPath 1.0, string-length() defaults to the string-value of the context node when called without an argument, but Functions.string_length required a positional argument and raised ArgumentError.

REXML::XPath.match(REXML::Document.new('<root><item>123</item><item>1234</item><item>12345</item></root>'), '//item[string-length()=4]')
# before: wrong number of arguments (given 0, expected 1) (ArgumentError)
# after:  matches the <item>1234</item> element

Defaults the argument to @context[:node] to match string and normalize_space.

@naitoh naitoh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@naitoh
naitoh merged commit e238ba5 into ruby:master Jul 5, 2026
66 of 73 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants